package bsc.war.handler;


import bsc.ejb.entity.Dimension;
import bsc.ejb.entity.DimensionMember;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author memozac
 */
public class AddDimensionMember extends AbstractController  {

     @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
         HttpServletResponse response) throws Exception {
        
        try {
            DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");
            
            // miembro padre y dimension
            Long idDimension = request.getParameter("dimension") != null && NumberUtils.isNumber(request.getParameter("dimension")) ? Long.parseLong(request.getParameter("dimension")) : null;
            Long idDimensionMember = request.getParameter("dimensionMember") != null && NumberUtils.isNumber(request.getParameter("dimensionMember")) ? Long.parseLong(request.getParameter("dimensionMember")) : null;

            Dimension dimension = delegate.findDimension(idDimension);
            DimensionMember dimensionMember = delegate.findDimensionMember(idDimensionMember);

            request.setAttribute("dimension", dimension);
            request.setAttribute("dimensionMember", dimensionMember);
                        
        } catch (Exception e) {
        }
         
         return new ModelAndView("addDimensionMember");
    }

}
